#include "VictoryConditions.h"

#include "ParticleContext.h"
#include "DescriptorParticle.h"
#include "ParticleBase.h"

#include "ParticleVictoryKeepAll.h"
#include "ParticleVictoryDestroyAll.h"

using namespace ParticleEngine;

VictoryConditions::VictoryConditions(ParticleContext& NewContext) :
Context(NewContext),
//ToKeep(0),
ToDestroy(0),
Lost(false),
Won(false)
{

};

VictoryConditions::~VictoryConditions()
{

};

void VictoryConditions::Reset()
{
	Lost = false;
	Won = false;
	ToDestroy = 0;
	/*
	for (size_t i = 0; i < Context.ParticleCount; i++)
	{
		if (Context.Par[i]->Descriptor->Name == std::string("VictoryKeepAll"))
		{
			dynamic_cast<ParticleVictoryKeepAll*>(Context.Par[i])->Active = false;
		}
		if (Context.Par[i]->Descriptor->Name == std::string("VictoryDestroyAll"))
		{
			ToDestroy++;
			dynamic_cast<ParticleVictoryDestroyAll*>(Context.Par[i])->Active = false;
		}
	}*/
}

void VictoryConditions::KeepAllReleased()
{
	if (Won == false)
		Lost = true;
}

void VictoryConditions::DestroyAllReleased()
{
	if (Lost == false)
	{
		ToDestroy--;
		if (ToDestroy <= 0)
			Won = true;
	}
}